﻿<Window x:Class="SDF.Test.ConvertedDocuments"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="http://sdf.codeplex.com/"
        Title="Converted documents sample" 
        Height="600" Width="700"
        WindowStartupLocation="CenterScreen">

    <Grid Margin="4">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Label>Select the file to view:</Label>
        <ComboBox Grid.Column="1"
                  ItemsSource="{Binding SampleDocuments}"
                  DisplayMemberPath="Key"
                  SelectedValuePath="Key"
                  SelectedValue="{Binding SelectedDocumentName}" />
        
        <TabControl Grid.ColumnSpan="2" Grid.Row="1" SelectedIndex="1">
            
            <!-- FLOW VIEW -->
            <TabItem Header="Flow View">
                <Grid Background="LightGray">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="200"/>
                    </Grid.RowDefinitions>

                    <Border BorderBrush="Black" 
                            BorderThickness="1" 
                            Background="White"
                            Margin="4">
                        <FlowDocumentScrollViewer Document="{Binding SelectedDocument}" />
                    </Border>

                    <s:SmartDocumentViewer Document="{Binding ConvertedDocument}" Grid.Column="2" 
                                           BorderBrush="Black" 
                                           BorderThickness="1"
                                           Background="White"
                                           Padding="-1"
                                           Margin="4" />

                    <ScrollViewer Grid.Row="1" Margin="4" BorderBrush="Black" BorderThickness="1" Background="White">
                        <StackPanel Margin="10">
                            <TextBlock Margin="0,0,0,12" FontWeight="Bold">Errors</TextBlock>
                            <ItemsControl ItemsSource="{Binding ConvertionErrors}" />
                        </StackPanel>
                    </ScrollViewer>

                    <ScrollViewer Grid.Row="1" Grid.Column="2"  Margin="4" BorderBrush="Black" BorderThickness="1" Background="White">
                        <StackPanel Margin="10">
                            <TextBlock Margin="0,0,0,12" FontWeight="Bold">Warnings</TextBlock>
                            <ItemsControl ItemsSource="{Binding ConvertionWarnings}" />
                        </StackPanel>
                    </ScrollViewer>
                </Grid>

            </TabItem>
            <TabItem Header="Paged View">

                <Grid Background="LightGray">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <DocumentViewer Name="Original"
                                    Margin="4"
                                    Document="{Binding SystemPaginatedDocument}"
                                    VerticalOffset="{Binding VerticalOffset, ElementName=Smart, Mode=TwoWay}"
                                    HorizontalOffset="{Binding HorizontalOffset, ElementName=Smart, Mode=TwoWay}">
                    </DocumentViewer>

                    <DocumentViewer Name="Smart"
                                    Margin="4"
                                    Grid.Column="2"
                                    Document="{Binding SmartPaginatedDocument}">

                    </DocumentViewer>
                </Grid>

            </TabItem>
        </TabControl>
    </Grid>
</Window>
